﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using prufa.Models;
using prufa.ViewModels;
using prufa.Interfaces;

namespace prufa.Controllers
{
    public class HomeController : Controller
    {
        private IGameRepository _repository = null;

        public HomeController()
        { 
            _repository = new GameRepository();
        }

        public HomeController(IGameRepository rep)
        {
            _repository = rep;
        }

        //pass a Viewmodel called IndexGameLists to the view which consists of lists of games - HÖÞ
        public ActionResult Index()
        {
            IEnumerable<Game> LatestGames = _repository.GetLatestGames();
            IEnumerable<Game> mostplayed = _repository.GetMostPlayed();
            IEnumerable<Game> AllGames = _repository.GetAllGames();

            return View(new IndexGameLists { AllGames = AllGames, NewestGames = LatestGames, MostPlayed = mostplayed });
        }

        public ActionResult About()
        {           
            return View();
        }

        public ActionResult Contact()
        {           
            return View();
        }

    }
}
